-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved meshbuilder's mesh handling #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last minor change, then ready to merge.
src/rod/builder/primitives.py
Outdated
@@ -74,20 +74,12 @@ def __post_init__(self) -> None: | |||
AssertionError: If the scale is not a 3D vector. | |||
TypeError: If the mesh_path is not a str or pathlib.Path. | |||
""" | |||
mesh_path = pathlib.Path(self.mesh_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nit, this attribute could already be a pathlib.Path
object:
mesh_path = pathlib.Path(self.mesh_path) | |
mesh_path = self.mesh_path if isinstance(self.mesh_path, pathlib.Path) else pathlib.Path(self.mesh_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in e1a70b0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the suggestion @lorycontixd, merging. Thanks for the contribution!
With this pull request, I suggest to move the mesh loading part inside of a context manager to ensure that the file is properly closed, but most importantly to avoid a bug from trimesh where a string can be passed to
trimesh.load_mesh
, but internally it requires a file-like object. This way, the mesh is instantly loaded using a file object.Also, I added a logging warning from
MeshBuilder
when an empty mesh is loaded.